package com.AFH.test;

import android.graphics.Canvas;
import android.view.SurfaceHolder;

public class GameThread extends Thread {
	GameView gv;
	SurfaceHolder surfaceHolder;
	boolean DrawOn;
	boolean flag = false;
	boolean drawtower = false;
	int sleeptime = 20;
	int stringTime = 20;
	int surpriseTime = 50;

	// int startMonsterId=0;

	GameThread(GameView gv, SurfaceHolder surfaceHolder) {
		super.setName("GameThread");
		this.gv = gv;
		this.surfaceHolder = surfaceHolder;
		DrawOn = true;
		flag = true;

	}

	@Override
	public void run() {

		while (flag) {
			// int count = 0;
			// int speed = 2;
			// Rect dirty = new Rect(800-speed,160,880-speed,240);

			Canvas canvas = null;
			while (DrawOn) {

				try {
					canvas = surfaceHolder.lockCanvas(null);
					synchronized (surfaceHolder) {
						// BitmapManager.DrawbackgroundResource(0, canvas, 0, 0,
						// null);

						// gv.RippleSpread();
						// gv.render();
						switch (gv.status) {
						case 0:
							if (gv.bgx > 0) {
								gv.bgx -= 80;
								gv.bgy -= 48;
							}
							else gv.status=1;

							break;
						case 1:
							break;
						}
					
						gv.doDraw(canvas);
						//canvas.drawBitmap(gv.memBm,0,0,null);

					}

				} catch (Exception e) {
					e.printStackTrace();
				} finally {
					surfaceHolder.unlockCanvasAndPost(canvas);
				}
				try {
					Thread.sleep(sleeptime);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			try {// 閿熸枻鎷烽敓绐栴叏鎷烽敓鍓款垽鎷烽敓锟�
				Thread.sleep(2000);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
